<template>
    <div class="Layout">
        <div class="top" v-hiddentop>
            <top-box></top-box>
        </div>
        <div class="zl" v-hiddencolumn>
            <defalut-column></defalut-column>
        </div>
        <div class="main">
            <defaultBox ref="defaultRef"></defaultBox>
            <div class="changeCard" @click="updateVideo"><img src="@/assets/videoCardIcon/change.png" ref="changeImgRef">换一换</div>
            <footer-box ref="footRef"></footer-box>
        </div>
        <div class="loading" v-loadata>
            <span v-loading="true" element-loading-text="Loading..."></span>
        </div>
        
    </div>
    <Transition name="showLoginPopup">
      <div v-if="store.state.isShowLoginPopup" class="showBox">
          <login-popup></login-popup>
      </div>
  </Transition>
</template>

<script lang="ts" setup>
import { ref,onMounted } from 'vue'
import { footerBox,defaultBox } from './index.ts'
import {useStore} from 'vuex'
import topBox from '@/layout/Top/index.vue'
import defalutColumn from '@/layout/ZL/compontens/defalutColumn.vue'
import LoginPopup from '@/components/loginPopup.vue'

const footRef = ref()
const defaultRef = ref()
const changeImgRef = ref()
const store = useStore()

//由于自定义指令存在闪烁问题 这里元素挂载时即表示页面刷新后 初始化栏目
//解决自定义指令在重新登录页面时 出现的bug现象 --- 好像并未解决 仍然存在少数情况下
onMounted(() => {
    store.commit('setIsScrollHegiht',false) 
    store.commit('setisScrollShow',false)
})

//当加载组件出现时 添加数据
const vLoadata = {
    mounted: (el:HTMLElement) => {    
        const observer = new IntersectionObserver((enr)=>{
            if (enr[0].intersectionRatio > 0){
                let timer = setTimeout(() => {
                    clearTimeout(timer)
                    footRef.value.initData()
                },500)
            }
        })
        observer.observe(el);
    }
}
function updateVideo(){
    defaultRef.value.initData()
    changeImgRef.value.classList.add('rotate')
    let timer = setTimeout(() => {
        clearTimeout(timer)
        changeImgRef.value.classList.remove('rotate')
    },1000)
}
</script>

<style lang="scss" scoped>
@import url(../../../assets/css/LoginPopup.scss);
@import url(../../../assets/css/videoAfterChangeCard.scss);
.Layout{
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    width: 100%;
    max-width: 2200px;
    min-width: 1200px;
    height: 100vh;
    gap: 15px;
}
.top{
    flex-shrink: 0;
    width: 100%;
    height: 160px;
    background-image:url('../../../assets/png/1b5dcf49b2f29812842c1a60f054148eef714626.png@3840w_360h_1c_90q.webp');
    padding: 0;
    display: flex;
    justify-content: center;
}
.zl{
    flex-shrink: 0;
    width: 90%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.main{
    position: relative;
    width: 100%;
    @include flexRowCenter;
    display: flex;
    flex-direction: column;
}
.loading{
    margin-top: 30px;
    width: 100%;
    height: 80px;
    @include flexRowCenter;
}
</style>